/*
 * @Author: your name
 * @Date: 2021-12-21 09:25:34
 * @LastEditTime: 2021-12-21 16:03:09
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \am\am\am-server\app\controller\player.js
 */
const { Controller } = require('egg');
const Message = require('../utils/Message')

/**
 * @Controller player-controller:运动员相关接口
*/

class PlayerController extends Controller {
     /**
   * @Router get /player/pageQuery
   * @summary 分页查询运动员信息
   * @request query string *page
   * @request query string *pageSize
   * @apikey
  */

  async pageQuery () {
    const { ctx, service } = this
    const playersVM = await service.player.pageQuery(ctx.query)

    ctx.body = Message.success(playersVM)
  }
  /**
   * @Router post /player/saveOrUpdate
   * @summary 保存或修改运动员信息
   * @request query number id
   * @request query string *name
   * @request query string *age
   * @request query string *height
   * @request query string *weight
   * @apikey
  */
   async saveOrUpdate () {
    const { ctx, service } = this
    // 接受用户请求 
    // 获取用户参数 ctx.query 
    // 调用service查询
    await service.player.saveOrUpdate(ctx.query)
    ctx.body = Message.success("操作成功")
  }
}

module.exports = PlayerController;